package com.shy.springframework.context.support;

import com.shy.springframework.beans.factory.ConfigurableListableBeanBeanFactory;
import com.shy.springframework.beans.factory.support.DefaultListableBeanBeanFactory;

public abstract class AbstractRefreshableApplicationContext extends AbstractApplicationContext{
    private DefaultListableBeanBeanFactory beanFactory;

    @Override
    protected void refreshBeanFactory() {
        DefaultListableBeanBeanFactory beanFactory = createBeanFactory();
        loadBeanDefinitions(beanFactory);
        this.beanFactory = beanFactory;
    }

    private DefaultListableBeanBeanFactory createBeanFactory(){
        return new DefaultListableBeanBeanFactory();
    }

    protected abstract void loadBeanDefinitions(DefaultListableBeanBeanFactory beanFactory);


    @Override
    protected ConfigurableListableBeanBeanFactory getBeanFactory() {
        return beanFactory;
    }

}
